<template>
  <div class="home">
    <div class="home-header">
      <Header />
      <Tab :tabs="tabs" />
    </div>
    <div style="width:100%;height:88px;"></div>

    <router-view
      class="home_router-view"
      :style="{ paddingBottom: pad }"
      v-slot="{ Component }"
    >
      <transition appear name="slide">
        <keep-alive>
          <component :is="Component" />
        </keep-alive>
      </transition>
    </router-view>

    <!-- <keep-alive :max="10">
      <router-view class="home_router-view" :style="{ paddingBottom: pad }">
      </router-view>
    </keep-alive> -->
  </div>
</template>

<script>
import Header from '@/components/Header'
import Tab from '@/components/Tab'
// import { mapState } from 'vuex'

export default {
  name: 'home',
  components: {
    Header,
    Tab
  },
  data() {
    return {
      // styleObject: {
      //   paddingBottom: '0px'
      // },
      tabs: [
        {
          name: '推荐',
          path: '/recommend'
        },
        {
          name: '歌手',
          path: '/singer'
        },
        {
          name: '排行',
          path: '/list'
        },
        {
          name: '搜索',
          path: '/search'
        }
      ]
    }
  },
  computed: {
    // ...mapState(['playlist', 'fullScreen']),
    pad() {
      return this.$store.state.playlist.length > 0 ? '60px' : '0'
    }
  },
  watch: {
    // playlist: function(newList) {
    //   if (newList.length > 0) {
    //     this.styleObject.paddingBottom = '60px'
    //   }
    // }
  }
}
</script>

<style lang="scss">
.home {
  // padding-top: 88px;
  .home-header {
    background-color: $color-background;
    width: 100%;
    height: 88px;
    position: fixed;
    z-index: 2999;
    left: 0;
    top: 0;
  }
  .home_router-view {
    // height: calc(100vh-88px);
  }
}
</style>
